/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-11-26
 * Time: 21:39
 */
//四：只出现一次的数字||
class Solution9 {
    public int singleNumber(int[] nums) {
        //这一层for循环i作为比特位
        int ret = 0;
        for(int j = 0 ; j < 32 ; j++){
            //所有元素的该bit位相加
            int sum = 0;
            for(int i = 0 ; i < nums.length ; i++){
                sum += (nums[i]>>j)&1;
            }
            int tem = sum % 3;
            if(tem == 1){
                ret |= (1<<j);
            }else{
                ret &= ~(1<<j);
            }
        }
        return ret;

    }
}
public class Test9 {
}
